import request from '../../utils/request'



interface IMemberLogin{
  saleOrganizationID:string
  memberID?:string
  phoneNumber?:string
}
//会员登录
export  function memberLogin(data:IMemberLogin) {
  return request({
    url: '/member/user/pos/details',
    method: 'get',
    params:data
   
  })
}

interface IMemberRegister{
  saleOrganizationID:string
  saleOrganizationName:string
  shopID:string
  shopName:string
  phoneNumber:string
  userID:string
  userName:string

}
//注册会员
export  function memberRegister(data:IMemberRegister) {
  return request({
    url: '/member/user/pos/add',
    method: 'post',
    data
   
  })
}



//获取优惠券信息
export  function getMemberCoupon(saleOrganizationID:string,shopID:string,memberID:string) {
  return request({
    url: '/member/coupon/pos/getCoupon',
    method: 'get',
    params:{saleOrganizationID,shopID,memberID}
   
  })
}

//获取充值活动
export  function getRechargeActivity(shopID:string) {
  return request({
    url: '/marketing/activityMember/pos/activityMemberRecharge',
    method: 'get',
    params:{shopID}
   
  })
}

type rechargeObj = {
  payType:string
  payTypeText:string
  memberID:string
  memberPhoneNumber:string
  capital:string
  giveCash:string
  receivableAmount:string
  saleOrganizationID:string
  saleOrganizationName:string
  shopID:string
  shopName:string
  shopCode:string
  basicActivityID:string
  basicActivityName:string
  memberRechargeConfigID:string
  balanceRecordCouponAddDtos:Array<object>
  authCode?:string
}


//现金充值
export  function cashRecharge(data:rechargeObj) {
  return request({
    url: '/sale/order/pos/balanceOrder',
    method: 'post',
    data
   
  })
}


  



    // /**
    //  * 订单应收金额
    //  */
    // private BigDecimal receivableAmount;

    // /**
    //  * 销售组织机构（t_BM_Organization）ID int
    //  */
    // private Integer saleOrganizationID;

    // /**
    //  * 销售组织机构（t_BM_Organization）Name_K
    //  */
    // private String saleOrganizationName;

    // /**
    //  * 店铺ID
    //  */
    // private Integer shopID;

    // /**
    //  * 店铺名称
    //  */
    // private String shopName;

    // /**
    //  * 付款码
    //  */
    // private String authCode;

    // /**
    //  * 充值活动基础ID（t_MKT_BasicActivity）ID
    //  */
    // private Long basicActivityID;

    // /**
    //  * 充值活动名称（t_MKT_BasicActivity）Name
    //  */
    // private String basicActivityName;

    // /**
    //  * 充值活动配置ID（t_MKT_MemberRechargeConfig）ID
    //  */
    // private Long memberRechargeConfigID;

    // /**
    //  * 会员充值优惠券
    //  */
    // private List<BalanceRecordCouponAddDto> balanceRecordCouponAddDtos;


    interface IOrderPayAddDto{
      payType:string //付款方式
      payTypeText:string
      payAmount?:string //付款金额(如果是会员则是实际会员需要支付的本金（如果赠金不够的话））
      giveCash?:string //付款金额(如果是会员则是会员需要支付的赠金）
    }
    interface IOrderPayDto{
      authCode:string //付款码
      payAmount:string //网络支付金额
      orderPayAddDtos:Array<IOrderPayAddDto> //其它支付方式
    }
    interface IOrderDetailAddDto{
      goodsID:string
      goodsName:string
      basicPrice:string //基础价格
      retailPrice:string //零售价
      buyingPrice:string //进货价
      quantity:string //数量 
      
      payAmount:string //付款金额（活动计算之后的金额）
      saleUnit:string //销售单位
      inventoryUnit:string //库存单位
      saleUnitID_K:string //销售单位（t_BM_Unit）金蝶计量单位内码
      inventoryUnitID_K:string //库存单位（t_BM_Unit）金蝶计量单位内码
      priceActivityID:string //单价类促销活动ID
      otherActivityID:string //其它类促销活动ID
      couponID:string //优惠券ID
      memberCouponID:string //使用的会员优惠券ID
      activityDiscount:string //订单促销优惠额度（加权平均活动优惠）
      couponDiscount:string //订单促销优惠额度（加权平均活动优惠）
      isGift:string //是否赠品 （0 非赠品  1赠品）
    }

    //创建店铺订单
    interface IOrder{
      offineID?:string //离线订单id
      saleOrganizationID:string
      saleOrganizationName:string
      shopID:string
      shopName:string
      memberID?:string
      memberPhoneNumber?:string
      priceSchemesID?:string //价格方案id
      originalAmount:string //订单金额（原价）
      receivableAmount:string //订单应收金额
      discountAmount:string //订单优惠金额
      goodsQuantity:number //订单商品件数
      orderTime:string //下单时间
      orderPayDto:IOrderPayDto //订单支付明细
      orderDetailAddDtos:Array<IOrderDetailAddDto> //订单商品明细
      memberCouponPOSDtos:Array<any> //订单创建优惠券
      memberCouponIDs:Array<any> //使用会员优惠券id
      priceType:string //价格类型
      priceTypeText:string
    }
    export  function createOrder(data:IOrder) {
      return request({
        url: '/sale/order/createOrder',
        method: 'post',
        data
      })
    }



    //会员余额扫付款码 获取会员信息
    
    export  function getMemberInfoByCode(saleOrganizationID,payCode,memberID) {
      return request({
        url: '/member/balance/pos/payCode',
        method: 'get',
        params:{saleOrganizationID,payCode,memberID}
       
      })
    }



    //查看购物卡余额
    export  function getShoppingCardBalance(cardNumber,shopID) { //deductAmount扣减金额
      return request({
        url: '/marketing/shoppingCardDetail/pos/getBalance',
        method: 'post',
        data:{cardNumber,shopID}
       
      })
    }